package com.chen.hotel.controller;

import com.chen.hotel.Service.ImageService;
import com.chen.hotel.VO.ResultVO;
import com.chen.hotel.annotation.LoginToken;
import com.chen.hotel.domain.Images;
import com.chen.hotel.utils.ResultVOUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/image")
public class ImageController {

    @Autowired
    private ImageService imageService;

    /**
     * 添加一张图片
     */
    @PostMapping("")
    @LoginToken
    public ResultVO create(@RequestBody Images images){
        return ResultVOUtil.success(this.imageService.create(images));
    }

    /**
     * 删除一张图片
     */
    @DeleteMapping("/{id}")
    @LoginToken
    public ResultVO delete(@PathVariable Integer id){
        this.imageService.delete(id);
        return ResultVOUtil.success(null);
    }
}
